#include "in.h"

int TTSelectBatch_user_info( struct MemTable *table , struct UserInfo *user_info_array , size_t user_info_array_size )
{
	size_t		user_info_array_count ;
	int		i ;
	
	int		nret = 0 ;
	
	memset( user_info_array , 0x00 , sizeof(struct UserInfo) * user_info_array_size );
	printf( "MDBSelectBatch ...\n" );
	nret = MDBSelectBatch( table , user_info_array , user_info_array_size , & user_info_array_count , MDBFIELD(struct UserInfo,uid) , MDBFIELD(struct UserInfo,user_name) , MDBFIELD(struct UserInfo,email) , MDBFIELD_NONE , NULL , MDBFIELD_NONE ) ;
	if( nret )
	{
		printf( "MDBSelectBatch failed[%d]\n" , MDBGetLastError() );
		return nret;
	}
	else
	{
		printf( "MDBSelectBatch ok , user_info_array_count[%zu]\n" , user_info_array_count );
		for( i = 0 ; i < MIN(user_info_array_count,user_info_array_size) ; i++ )
		{
			printf( "    uid[%"PRIu32"] user_name[%s] email[%s]\n" , user_info_array[i].uid , user_info_array[i].user_name , user_info_array[i].email );
		}
		return 0;
	}
}

int TTSelectBatch_user_friend_relation( struct MemTable *table , struct UserFriendRelation *user_friend_relation_array , size_t user_friend_relation_array_size )
{
	size_t		user_friend_relation_array_count ;
	int		i ;
	
	int		nret = 0 ;
	
	memset( user_friend_relation_array , 0x00 , sizeof(struct UserFriendRelation) * user_friend_relation_array_size );
	printf( "MDBSelectBatch ...\n" );
	nret = MDBSelectBatch( table , user_friend_relation_array , user_friend_relation_array_size , & user_friend_relation_array_count , MDBFIELD(struct UserFriendRelation,user_name) , MDBFIELD(struct UserFriendRelation,friend_name) , MDBFIELD_NONE , NULL , MDBFIELD_NONE ) ;
	if( nret )
	{
		printf( "MDBSelectBatch failed[%d]\n" , MDBGetLastError() );
		return nret;
	}
	else
	{
		printf( "MDBSelectBatch ok , user_friend_relation_array_count[%zu]\n" , user_friend_relation_array_count );
		for( i = 0 ; i < MIN(user_friend_relation_array_count,user_friend_relation_array_size) ; i++ )
		{
			printf( "    user_name[%s] friend_name[%s]\n" , user_friend_relation_array[i].user_name , user_friend_relation_array[i].friend_name );
		}
		return 0;
	}
}

